package com.yootk.listener;

import jakarta.servlet.ServletContextEvent;
import jakarta.servlet.ServletContextListener;
import jakarta.servlet.annotation.WebListener;

/**
 * Servlet上下文监听
 */
@WebListener
public class WebContextListener implements ServletContextListener {

    @Override
    public void contextInitialized(ServletContextEvent sce) { // 容器启动时调用
        System.out.println("【WebContextListener.contextInitialized()】Servlet上下文初始化：" + sce.getServletContext().getVirtualServerName());
    }

    @Override
    public void contextDestroyed(ServletContextEvent sce) { // 容器关闭时调用
        System.out.println("【WebContextListener.contextDestroyed()】Servlet上下文销毁：" + sce.getServletContext().getVirtualServerName());
    }
}
